package com.qms.repast.ui.activity;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.qms.repast.R;
import com.qms.repast.entity.resbean.SortBean;
import com.qms.repast.ui.adapter.SortAdapter;
import com.qms.repast.ui.base.BaseActivity;
import com.qms.repast.ui.presenter.SortPresenter;
import com.qms.repast.ui.view.ISortView;
import com.qms.repast.utils.AppUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author 泅渡者
 * @date 2018/9/7 0007
 * @describe: 排序界面
 */
public class SortActivity extends BaseActivity<SortPresenter> implements ISortView {
	@BindView(R.id.iv_delete)
	ImageView ivDelete;
	@BindView(R.id.lv_sort)
	ListView lvSort;

	private List<SortBean> sortBeans;
	private SortAdapter sortAdapter;

	@Override
	protected int initLayout () {
		return R.layout.activity_sort;
	}

	@Override
	protected void initPresenter (Intent intent) {
		mPresenter = new SortPresenter(this, this);
	}

	@Override
	protected void initView () {
		sortBeans = new ArrayList<>();
		sortBeans.add(new SortBean(R.mipmap.icon_location, "距离"));
		sortBeans.add(new SortBean(R.mipmap.icon_price, "价格"));
		sortBeans.add(new SortBean(R.mipmap.icon_price, "价格"));
		sortBeans.add(new SortBean(R.mipmap.icon_like, "点赞"));
		sortBeans.add(new SortBean(R.mipmap.icon_buy, "购买数"));
		sortBeans.add(new SortBean(R.mipmap.icon_praise, "好评度"));
		sortAdapter = new SortAdapter(AppUtils.getContext(), sortBeans);
		lvSort.setAdapter(sortAdapter);
		lvSort.setOnItemClickListener(new AdapterView.OnItemClickListener() {
			@Override
			public void onItemClick (AdapterView<?> adapterView, View view, int position, long l) {
				sortAdapter.setChooseId(position);
			}
		});
	}

	@Override
	protected void initData () {

	}

	@OnClick(R.id.iv_delete)
	public void onViewClicked () {
		finish();
	}
}
